﻿/**  版本信息模板在安装目录下，可自行修改。
* FA_MASTERDATA_EXCEL_PROPERTY.cs
*
* 功 能： N/A
* 类 名： FA_MASTERDATA_EXCEL_PROPERTY
*
* Ver    变更日期             负责人  变更内容
* ───────────────────────────────────
* V0.01  2013/10/14 11:17:06   N/A    初版
*
* Copyright (c) 2012 TKFA Corporation. All rights reserved.
*┌──────────────────────────────────┐
*│　此技术信息为本公司机密信息，未经本公司书面同意禁止向第三方披露．　│
*│　版权所有：TKFA　　　　　　　　　　　　　　│
*└──────────────────────────────────┘
*/
using System;
using System.Data;
using System.Text;
using System.Data.OracleClient;
using TKFA.IDAL;
using Maticsoft.DBUtility;//Please add references
namespace TKFA.OracleDAL
{
	/// <summary>
	/// 数据访问类:FA_MASTERDATA_EXCEL_PROPERTY
	/// </summary>
	public partial class FA_MASTERDATA_EXCEL_PROPERTY:IFA_MASTERDATA_EXCEL_PROPERTY
	{
		public FA_MASTERDATA_EXCEL_PROPERTY()
		{}
		#region  BasicMethod



		/// <summary>
		/// 增加一条数据
		/// </summary>
		public bool Add(TKFA.Model.FA_MASTERDATA_EXCEL_PROPERTY model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into FA_MASTERDATA_EXCEL_PROPERTY(");
			strSql.Append("SCODE,SNAME,SCOLUMNNAME)");
			strSql.Append(" values (");
			strSql.Append(":SCODE,:SNAME,:SCOLUMNNAME)");
			OracleParameter[] parameters = {
					new OracleParameter(":SCODE", OracleType.VarChar,20),
					new OracleParameter(":SNAME", OracleType.VarChar,20),
					new OracleParameter(":SCOLUMNNAME", OracleType.VarChar,20)};
			parameters[0].Value = model.SCODE;
			parameters[1].Value = model.SNAME;
			parameters[2].Value = model.SCOLUMNNAME;

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(TKFA.Model.FA_MASTERDATA_EXCEL_PROPERTY model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update FA_MASTERDATA_EXCEL_PROPERTY set ");
			strSql.Append("SCODE=:SCODE,");
			strSql.Append("SNAME=:SNAME,");
			strSql.Append("SCOLUMNNAME=:SCOLUMNNAME");
			strSql.Append(" where ");
			OracleParameter[] parameters = {
					new OracleParameter(":SCODE", OracleType.VarChar,20),
					new OracleParameter(":SNAME", OracleType.VarChar,20),
					new OracleParameter(":SCOLUMNNAME", OracleType.VarChar,20)};
			parameters[0].Value = model.SCODE;
			parameters[1].Value = model.SNAME;
			parameters[2].Value = model.SCOLUMNNAME;

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete()
		{
			//该表无主键信息，请自定义主键/条件字段
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from FA_MASTERDATA_EXCEL_PROPERTY ");
			strSql.Append(" where ");
			OracleParameter[] parameters = {
			};

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public TKFA.Model.FA_MASTERDATA_EXCEL_PROPERTY GetModel()
		{
			//该表无主键信息，请自定义主键/条件字段
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select SCODE,SNAME,SCOLUMNNAME from FA_MASTERDATA_EXCEL_PROPERTY ");
			strSql.Append(" where ");
			OracleParameter[] parameters = {
			};

			TKFA.Model.FA_MASTERDATA_EXCEL_PROPERTY model=new TKFA.Model.FA_MASTERDATA_EXCEL_PROPERTY();
			DataSet ds=DbHelperOra.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				return DataRowToModel(ds.Tables[0].Rows[0]);
			}
			else
			{
				return null;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public TKFA.Model.FA_MASTERDATA_EXCEL_PROPERTY DataRowToModel(DataRow row)
		{
			TKFA.Model.FA_MASTERDATA_EXCEL_PROPERTY model=new TKFA.Model.FA_MASTERDATA_EXCEL_PROPERTY();
			if (row != null)
			{
				if(row["SCODE"]!=null)
				{
					model.SCODE=row["SCODE"].ToString();
				}
				if(row["SNAME"]!=null)
				{
					model.SNAME=row["SNAME"].ToString();
				}
				if(row["SCOLUMNNAME"]!=null)
				{
					model.SCOLUMNNAME=row["SCOLUMNNAME"].ToString();
				}
			}
			return model;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select SCODE,SNAME,SCOLUMNNAME ");
			strSql.Append(" FROM FA_MASTERDATA_EXCEL_PROPERTY ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperOra.Query(strSql.ToString());
		}

		/// <summary>
		/// 获取记录总数
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) FROM FA_MASTERDATA_EXCEL_PROPERTY ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			object obj = DbHelperSQL.GetSingle(strSql.ToString());
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("SELECT * FROM ( ");
			strSql.Append(" SELECT ROW_NUMBER() OVER (");
			if (!string.IsNullOrEmpty(orderby.Trim()))
			{
				strSql.Append("order by T." + orderby );
			}
			else
			{
				strSql.Append("order by T.SCODE desc");
			}
			strSql.Append(")AS Row, T.*  from FA_MASTERDATA_EXCEL_PROPERTY T ");
			if (!string.IsNullOrEmpty(strWhere.Trim()))
			{
				strSql.Append(" WHERE " + strWhere);
			}
			strSql.Append(" ) TT");
			strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
			return DbHelperOra.Query(strSql.ToString());
		}

		/*
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		{
			OracleParameter[] parameters = {
					new OracleParameter(":tblName", OracleType.VarChar, 255),
					new OracleParameter(":fldName", OracleType.VarChar, 255),
					new OracleParameter(":PageSize", OracleType.Number),
					new OracleParameter(":PageIndex", OracleType.Number),
					new OracleParameter(":IsReCount", OracleType.Clob),
					new OracleParameter(":OrderType", OracleType.Clob),
					new OracleParameter(":strWhere", OracleType.VarChar,1000),
					};
			parameters[0].Value = "FA_MASTERDATA_EXCEL_PROPERTY";
			parameters[1].Value = "SCODE";
			parameters[2].Value = PageSize;
			parameters[3].Value = PageIndex;
			parameters[4].Value = 0;
			parameters[5].Value = 0;
			parameters[6].Value = strWhere;	
			return DbHelperOra.RunProcedure("UP_GetRecordByPage",parameters,"ds");
		}*/

		#endregion  BasicMethod
		#region  ExtensionMethod

		#endregion  ExtensionMethod
	}
}

